<?php
require_once 'application/constant/constant.php';
require_once 'application/library/db/gcDbUpdate.php';
require_once 'application/library/db/gcDbSelect.php';
require_once 'application/library/helper/userDataHelper.php';

/**
 * DB操作用类
 * gcBBasicDao
 * @author    Soochow University
 * @version   1.0
 * @exclude   作  成  日：2011/04/07
 */
class gcBBasicDao{

    /**
     * 表
     */
    protected $_table;

    /**
     * 数据取得
     */
    private $select;

    /**
     * 数据更新
     */
    private $update;

    /**
     * __construct
     */
    public function __construct(){
        $this->select= new gcDbSelect();
        $this->update= new gcDbUpdate($this->_table);
    }
    
    /**
     * 数据取得
     * Select
     * @param   string  $sql
     * @param   array   $parameter
     * @param   string  $type
     * @return  array
     */
    public function select($sql,$parameter,$type){
        $select = $this->select->Select($sql, $parameter,$type);
        return $select;
    }

    /**
     * 数据登录
     * Insert
     * @param   obj     $obj
     * @param   array   $parameter
     * @return  string  $insert
     */
    public function insert($obj,$parameter){
        $insert = $this->update->Insert($obj, $parameter);
        return $insert;
    }

    /**
     * 批量数据登录
     * batchInsert
     * @param   obj     $obj
     * @param   array   $parameter
     * @return  int     $count
     */
    public function batchInsert($obj,$parameter){
        $count = $this->update->batchInsert($obj, $parameter);
        return $count;
    }

    /**
     * 数据更新
     * Update
     * @param   obj     $obj 
     * @param   array   $parameter 
     * @param   array   $where
     * @return  string  $count
     */
    public function update($obj,$parameter,$where=NULL){
        $count = $this->update->Update($obj, $parameter,$where);
        return $count;
    }
    
    /**
     * 数据消除
     * delete
     * @param   string  $sql 
     * @param   array   $parameter 
     * @param   array   $where
     * @return  string  $count
     */
    public function delete($sql,$Parameter,$where=null){
        $count = $this->update->Delete($sql, $Parameter,$where);
        return $count;
    }
    
    /**
     * DbNameを設定する
     * setDbName
     * @param string $dbName
     */
    public function setDbName() {
       $this->select= new gcDbSelect();
       $this->update= new gcDbUpdate($this->_table);
    }

}